local hx__zhenshen = fk.CreateSkill {
  name = "hx__zhenshen",
  tags = { Skill.Compulsory },
}


hx__zhenshen:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(hx__zhenshen.name) and Fk:currentRoom().current == player then
      --[[
      local room = player.room
      local slash = false
      local phase_ids = {}
      local slashs = {}
      local mark = player:getMark(MarkEnum.SlashResidue) + player:getMark(MarkEnum.SlashResidue.."-turn") + player:getMark(MarkEnum.SlashResidue.."-round")
      room.logic:getEventsOfScope(GameEvent.Phase, 1, function(e)
        if e.data.phase == Player.Play then
          table.insert(phase_ids, { e.id, e.end_id })
        end
      end, Player.HistoryTurn)
      if #phase_ids > 0 then
        room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
          local in_play = false
          for _, ids in ipairs(phase_ids) do
            if #ids == 2 and e.id > ids[1] and e.id < ids[2] then
              in_play = true
              break
            end
          end
          if in_play then
            local use = e.data
            if use.from == player and use.card.trueName == "slash" then
              table.insert(slashs, use.card)
            end
          end
          if #slashs >= 1 + mark or player:getMark("@hx__ninan-turn") >= mark then
            slash = true
          end
          if player:hasMark(MarkEnum.SlashBypassTimes) or player:hasMark(MarkEnum.SlashBypassTimes.."-turn") or player:hasMark(MarkEnum.SlashBypassTimes.."-round") then
            slash = false
          end
        end, Player.HistoryTurn)
      end
      --]]
      local cards = {}
      for _, move in ipairs(data) do
        if move.from == player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
              local card = Fk:getCardById(info.cardId)
              if (not player:canUse(card)) or player:prohibitUse(card) then
                table.insert(cards, card)
              end
            end
          end
        end
      end
      if #cards > 0 then
        event:setCostData(self, {num = #cards})
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(event:getCostData(self).num, hx__zhenshen.name)
    player.room:setPlayerMark(player, "@hx__ninan-turn", 0)
  end,
})


return hx__zhenshen
